/*
 * @Author: your name
 * @Date: 2022-03-14 14:49:26
 * @LastEditTime: 2022-03-14 14:49:27
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: /gomeshsync/config/log.go
 */

package config

import (
	"log"
	"os"
	"path/filepath"

	"gitee.com/kimsoso/go-utils/utils"
)

func setSystemLog() {
	c := GetConfig()
	if c.Log {
		file := filepath.Join(utils.GetCurrentAbPath(), "gms.log")
		logFile, err := os.OpenFile(file, os.O_RDWR|os.O_CREATE|os.O_APPEND, os.ModePerm)
		if err != nil {
			panic(err)
		}
		log.SetOutput(logFile) // 将文件设置为log输出的文件
	} else {
		log.SetOutput(os.Stdout)
	}

	log.SetPrefix("[gomeshsync]")
	log.SetFlags(log.LstdFlags | log.Lshortfile | log.LUTC)
}
